<%--
  Created by IntelliJ IDEA.
  User: ttq
  Date: 13-7-9
  Time: 下午3:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.ResultSet" %>
<jsp:directive.page import="java.sql.Date"></jsp:directive.page>
<jsp:directive.page import="java.sql.Timestamp"></jsp:directive.page>
<jsp:directive.page import="java.sql.SQLException"></jsp:directive.page>
<%@ page import="com.mysql.jdbc.AbandonedConnectionCleanupThread" %>
<%@ page import="com.mysql.jdbc.Driver" %>
<a href="addPerson.jsp">新建人员资料</a>
<%
    Connection connection = null;
    Statement statement = null;
    ResultSet resultSet = null;
    try {
        DriverManager.registerDriver(new Driver());
        connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/databaseWeb", "root", "123456");
        statement = connection.createStatement();
        resultSet = statement.executeQuery("select * from tb_person");
%>
<form action="operatePerson.jsp" method="get">
    <table bgcolor="#cccccc" cellpadding="1" cellspacing="1" width="100%">
        <tr bgcolor="#dddddd">
            <th>
                id
            </th>
        </tr>
        <%
            while (resultSet.next()) {
                int id = resultSet.getInt("id");
                out.println("<tr bgcolor='#FFFFFF'>");
                out.println("<td>" + id + "</td>");
                out.println("</tr>");
            }
        %>
    </table>
</form>
<%
    } catch (SQLException e) {
        out.println("发生了异常:" + e.getMessage());
        e.printStackTrace();
    } finally {
        if (resultSet != null)
            resultSet.close();
        if (statement != null)
            statement.close();
        if (connection != null)
            connection.close();
    }
%>
